home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM 1996 Fall / BMUG Fall'96 PD-ROM.iso / Education / Math / MathPad 2.4 / MathPadPPC / MathPadPPC.rsrc / TEXT_128_General Help.txt < prev    next >
Text File  |  1996-04-15  |  5KB  |  149 lines

  1. ~                       MathPad 2.4
  2.  
  3. MathPad may be used as a calculator simply by typing in the numbers and operators. When the ENTER key is hit, each line is evaluated and the results are inserted into the text. Variables and functions can be defined. Results can be plotted or tabulated.  Command period can be used to stop evaluation.
  4. ~
  5. ----------------------- Examples:
  6.  
  7. 21*(3+4)/2.4:61.2
  8.  
  9. 2 +     -- expressions are continued if the line ends with an operator
  10. 3*4:14.0
  11.  
  12. #+5:19.0;    -- # may be used to access the previous result
  13.  
  14. ------- variables and functions
  15. -- calculate a trajectory for initial velocity V, angle Theta.
  16.  
  17. Vx=V*cos(Theta)
  18. Vy=V*sin(Theta) when Theta > 0 and Theta < 180, 0 otherwise
  19. altitude(t)=Vy*t-(g/2)*t^2
  20. impact_time=2*(Vy/g)
  21. apogee=(Vy^2)/(2*g);   range=Vx*impact_time
  22.  
  23. g=9.8; V=100;  Theta=75
  24.  
  25. range:510.2;    apogee:476.0
  26.  
  27. ------- plotting
  28.  
  29. Xmin=0; Xmax=impact_time
  30. plot altitude(X)
  31. label apogee:476.0
  32.  
  33. -- Special variables used to control plot:
  34.  --  Title Ystrips
  35.  --  X Xmin Xmax Xsteps Xdiv Xlabel Xlogaxis Xshowgrid Xticklabels
  36.  --  Ymin Ymax Ydiv Ylabel Ylogaxis Yshowgrid Yticklabels
  37.  --  Zmin Zmax Zlabel Zlogaxis Zshowbar
  38. -- newaxis  allows multiple plots/page
  39.  
  40. ------- tables
  41.  
  42. table     N,       N^3
  43.         1.0        1.0
  44.         2.0        8.0
  45.         3.0       27.0
  46.         4.0       64.0
  47.         5.0      125.0
  48.         6.0      216.0
  49.         7.0      343.0
  50.         8.0      512.0
  51.         9.0      729.0
  52.        10.0     1000.0
  53.  
  54. -- Special variables used to control table:
  55.  --  N Nmin Nmax Nsteps 
  56.  
  57. ------- summation
  58. series(n) = sum(2*k-1,k,1,n)
  59. series(9):81.0
  60.  
  61. ------- recursion
  62. fact(n) = 1 when n ‚⧠0, fact(n-1)*n
  63. fact(50):3.0e+64
  64.  
  65. ------- arrays
  66. A={10,20,30}      -- Defines a 3 element array.
  67. A[2]:20.0;     -- Accesses the 2nd element. Index values start at 1.
  68. B={A,{40,50,60},A+1}   --Multidimensional array.
  69. B:{{10.0,20.0,30.0},{40.0,50.0,60.0},{11.0,21.0,31.0}}
  70. B[1]:{10.0,20.0,30.0}
  71. B[1][2]:20.0
  72. B[1,2]:20.0;   -- Both forms of indexing are allowed
  73. A[2:3]:{20.0,30.0};    -- [lo:hi] selects a sub array.
  74. A[:2]:{10.0,20.0};     -- lo and/or hi may be omitted.
  75.  
  76. Q[i]=i*11  --Arrays can be defined in terms of their index values.
  77. Q[2]:22.0
  78. -- dim[] can be used to set the number of elements
  79. I[i,j] = 1 when i=j, 0   dim[3,3]
  80. I:{{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}}
  81.  
  82. --Arrays may be used freely in expressions. Operations are performed on each element.
  83. A+Q:{21.0,42.0,63.0}
  84. 2+A:{12.0,22.0,32.0}
  85. log(A):{1.0,1.3,1.5}
  86. A*Q:{110.0,440.0,990.0}; --Note: this is not matrix multiply
  87. --Q[A]:? A[?];           --Arrays may not be used as index values
  88.  
  89. --Functions can use index values
  90. skip(zz,by)[i] = zz[i*by] dim[count(zz)/by]
  91. skip(A,3):{30.0}
  92. skip(Q,2):{22.0,44.0,66.0,...}
  93. multiply(A,B)[i,j] = sum(A[i,k]*B[k,j],k,1,count(B)) dim
  94.              [count(A),count(B[1])]
  95. multiply({A},I):{{10.0,20.0,30.0}}
  96.  
  97. --Built-in functions for arrays
  98. count(A):3.0;  -- count() returns the number of array elements
  99.  count(B):3.0;  -- elements in 1st dimension
  100.  count(42):0.0; -- scalar
  101.  count(Q):?;    -- infinite array
  102. det(B):580.0;  -- calculates the determinant of a square matrix
  103. --read("pathname") returns an array of values read from the named file.
  104. --write("pathname",array)  writes the elements of the array to the named file.
  105.  
  106. --------- The table command can print 1D or 2D arrays
  107. table B
  108.        10.0       20.0       30.0
  109.        40.0       50.0       60.0
  110.        11.0       21.0       31.0
  111.  
  112. --------- The plot command can plot points from 1D or 2D arrays
  113. -- Arrays can be given in 5 forms:
  114.  -- parametric functions {fx(X),fy(X)}  X steps 0 to 1.0
  115.  -- array of y values    {y1,y2,y3...}
  116.  -- array of y functions {fy1(X),fy2(X),fy3(X),...}
  117.  -- array of x,y pairs   {{x1,y1},{x2,y2},{x3,y3},...}
  118.  -- a pair of arrays     {{x1,x2,...},{y1,y2,...}}
  119. -- To connect the points, use "plotline" instead of "plot".
  120. -- For {fx(X),fy(X)}, X is stepped from 0 to 1.0 and the resulting points are plotted in the range Xmin to Xmax.  This can be used for parametric equations:
  121.  
  122. deg=X*360; Xsteps=36      -- run deg from 0 to 360 in 10¬∞ steps
  123. x(angle)=5*cos(angle)+10  -- arbitrary scale to fit on existing plot
  124. y(angle)=100*sin(angle)+200
  125. plot {x(deg),y(deg)}
  126.  
  127. --------- The image command can display 2D arrays
  128. img[i,j]=(i-10)^2-5*j^2 dim[20,25]
  129. image img
  130. Zmax=95; Zmin=-500
  131.  
  132. --------- assignments
  133. -- The assignment operator := evaluates the right hand side expression and replaces any previous definition of the left hand variable with the result. Accessing the variable gives its current value.
  134. -- Assignments can only be done to simple global variables.
  135. -- Finite arrays may be assigned. A single numeric value can be assigned to an element of an array that has previously been initialized by assignment.
  136. -- The result of the := operation itself is always unknown. If you wish to access the result you must use the variable name. Multiple assignments can be performed using comma separated lists.
  137.  
  138. --------- iteration
  139. -- The 'while' operator can be used to evaluate some expression repeatedly.
  140.  
  141. factorial(n) = i:=1,m:=1,(i:=i+1,m:=m*i) while i<n, m
  142. factorial(50):3.0e+64
  143.  
  144. --------- include files
  145. -- include "pathname"  will open and read definitions from the specified file.
  146.  
  147. ---------------------------------------------------
  148. -- Questions and comments to: Mark.Widholm@UNH.edu
  149.